package com.qd.core.aspect.operarorlog;

import com.qd.common.sys.enums.OperatorType;
import com.qd.system.model.DataLog;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * 〈一句话功能简述〉<br>
 *
 * @author sjk
 * @since 1.0.0
 */
@Data
@Accessors(chain = true)
@EqualsAndHashCode
public class OperatorAopLog {
    /**
     * 是否记录数据日志
     */
    private boolean isAuditLog;
    private Long startTime;
    private String params;

    private String title;

    private String method;

    private OperatorType operatorType;

    private List<DataLog> dataLogList = new ArrayList<>(5000);

    public void addDataLog(DataLog dataLog) {
        dataLogList.add(dataLog);
    }

    public void freeData() {
        this.startTime = null;
        this.params = null;
        this.title = null;
        this.method = null;
        this.operatorType = null;
        Optional.of(dataLogList).ifPresent(List::clear);
    }

    public void clearDataLog() {
        dataLogList.clear();
    }
}